﻿using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using SportsPlatform.Authorization;
using SportsPlatform.Core.Model.SportBusiness;
using SportsPlatform.Dto.PermissionManagement.AuthorizationInfo;
using SportsPlatform.Dto.PermissionManagement.CompanyInfo;
using SportsPlatform.Dto.PermissionManagement.CompanyTypeInfo;
using SportsPlatform.Dto.PermissionManagement.DepartmentInfo;
using SportsPlatform.Dto.PermissionManagement.FunctionInfo;
using SportsPlatform.Dto.PermissionManagement.PlatformInfo;
using SportsPlatform.Dto.PermissionManagement.RoleFunction;
using SportsPlatform.Dto.PermissionManagement.RoleInfo;
using SportsPlatform.Dto.PermissionManagement.UserInfo;
using SportsPlatform.Dto.SportBusiness.AchievementOverPointInfo;
using SportsPlatform.Dto.SportBusiness.AchievementPunishmentInfo;
using SportsPlatform.Dto.SportBusiness.Category;
using SportsPlatform.Dto.SportBusiness.Competition;
using SportsPlatform.Dto.SportBusiness.CompetitionAchievementInfo;
using SportsPlatform.Dto.SportBusiness.CompetitionProjec;
using SportsPlatform.Dto.SportBusiness.Employee;
using SportsPlatform.Dto.SportBusiness.GetPaymentOrderInfo;
using SportsPlatform.Dto.SportBusiness.PaymentOrderOperationInfo;
using SportsPlatform.Dto.SportBusiness.ProjectType;
using SportsPlatform.Dto.WeChat;
using SportsPlatform.Dto.WeChat.Me;
using SportsPlatform.Model.PermissionManagement;
using SportsPlatform.Model.SportBusiness;
using SportsPlatform.Query.ClientLog;
using SportsPlatform.Query.Competition;
using SportsPlatform.Query.CompetitionProjec;
using SportsPlatform.Query.PermissionManagement.AuthorizationInfo;
using SportsPlatform.Query.PermissionManagement.CompanyInfo;
using SportsPlatform.Query.PermissionManagement.CompanyTypeInfo;
using SportsPlatform.Query.PermissionManagement.DepartmentInfo;
using SportsPlatform.Query.PermissionManagement.DepartmentRole;
using SportsPlatform.Query.PermissionManagement.FunctionInfo;
using SportsPlatform.Query.PermissionManagement.PlatformInfo;
using SportsPlatform.Query.PermissionManagement.RoleInfo;
using SportsPlatform.Query.PermissionManagement.UserInfo;
using SportsPlatform.Query.SportBusiness.AchievementOverPointInfo;
using SportsPlatform.Query.SportBusiness.AchievementPunishmentInfo;
using SportsPlatform.Query.SportBusiness.Category;
using SportsPlatform.Query.SportBusiness.CompetitionAchievementInfo;
using SportsPlatform.Query.SportBusiness.CompetitionGroupingInfo;
using SportsPlatform.Query.SportBusiness.Employee;
using SportsPlatform.Query.SportBusiness.EventsSession;
using SportsPlatform.Query.SportBusiness.Feedback;
using SportsPlatform.Query.SportBusiness.Information;
using SportsPlatform.Query.SportBusiness.PaymentOrderInfo;
using SportsPlatform.Query.SportBusiness.Project;
using SportsPlatform.Query.SportBusiness.ProjectType;
using SportsPlatform.Query.SportBusiness.RegistrationInfo;
using SportsPlatform.Query.SportBusiness.Team;
using SportsPlatform.Query.WeChat;
using GetCompetitionListDto = SportsPlatform.Dto.SportBusiness.CompetitionProjec.GetCompetitionListDto;

namespace SportsPlatform
{
    [DependsOn(
        typeof(SportsPlatformCoreModule),
        typeof(AbpAutoMapperModule))]
    public class SportsPlatformApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Authorization.Providers.Add<SportsPlatformAuthorizationProvider>();
            Configuration.Modules.AbpAutoMapper().Configurators.Add(config =>
            {
                #region AuthorizationInfo

                config.CreateMap<AddAuthorizationInfoQuery, AuthorizationInfo>();
                config.CreateMap<AuthorizationInfo, GetAuthorizationDetailedInfoListDto>();
                config.CreateMap<AuthorizationInfo, GetAuthorizationInfoListDto>();

                #endregion

                #region PlatformInfo

                config.CreateMap<AddPlatformInfoQuery, PlatformInfo>();
                config.CreateMap<PlatformInfo, GetPlatformInfoDto>();
                config.CreateMap<PlatformInfo, GetPaymentOderInfoDto>();
                config.CreateMap<GetPaymentOderInfoDto, PlatformInfo>();
                #endregion

                #region UserInfo

                config.CreateMap<AddUserInfoQuery, UserInfo>();
                config.CreateMap<UserInfo, GetLoginUserInfoDto>();
                config.CreateMap<UserInfo, GetUserInfoDto>();
                config.CreateMap<UserInfo, GetUserInfoListPageDto>();

                #endregion

                #region CompanyInfo

                config.CreateMap<AddCompanyInfoQuery, CompanyInfo>();
                config.CreateMap<CompanyInfo, GetCompanyInfoDto>();
                config.CreateMap<UpdateCompanyInfoQuery, CompanyInfo>();
                config.CreateMap<CompanyInfo, GetCompanyNameListDto>();
                config.CreateMap<CompanyInfo, GetCompanysSelectItemListQuery>();
                #endregion

                #region CompanyTypeInfo
                config.CreateMap<AddCompanyTypeInfoQuery, CompanyTypeInfo>();
                config.CreateMap<CompanyTypeInfo, GetCompanyTypeInfoDto>();
                #endregion

                #region RoleInfo

                config.CreateMap<AddRoleInfoQuery, RoleInfo>();
                config.CreateMap<RoleInfo, GetRoleInfoDto>();

                #endregion

                #region FunctionInfo

                config.CreateMap<AddFunctionInfoQuery, FunctionInfo>();
                config.CreateMap<FunctionInfo, GetFunctionInfoDto>();
                config.CreateMap<FunctionInfo, GetRoleFunctionDto>();
                config.CreateMap<FunctionInfo, GetFunctionInfoTreeDto>();

                #endregion

                #region DepartmentInfo

                config.CreateMap<DepartmentInfo, GetDepartmentInfoDto>();
                config.CreateMap<AddDepartmentInfoQuery, DepartmentInfo>();

                #endregion

                #region DepartmentRole

                config.CreateMap<AddDepartmentRoleQuery, DepartmentRole>();

                #endregion

                #region CompetitionAchievementInfo

                config.CreateMap<AddCompetitionAchievementInfoQuery, CompetitionAchievementInfo>();
                config.CreateMap<CompetitionAchievementInfo, EventsSessionCompetitionAchievementInfoDto>();
                config.CreateMap<CompetitionAchievementInfo, EventsSessionCompetitionAchievementInfoDetailsDto>();
                config.CreateMap<CompetitionAchievementInfo, CompetitionAchievementInfoDto>();
                config.CreateMap<CompetitionAchievementInfo, GetAchievementInfoDto>();
                config.CreateMap<AchievementInfoSynchronizationQuery, CompetitionAchievementInfo>();


                #endregion


                #region AchievementOverPointInfo

                config.CreateMap<AddAchievementOverPointInfoQuery, AchievementOverPointInfo>();
                config.CreateMap<AchievementOverPointInfo, AchievementOverPointInfoDto>();
                config.CreateMap<OverPointInfoSynchronizationQuery, AchievementOverPointInfo>();

                #endregion

                #region AchievementPunishmentInfo

                config.CreateMap<AddAchievementPunishmentInfoQuery, AchievementPunishmentInfo>();
                config.CreateMap<AchievementPunishmentInfo, AchievementPunishmentInfoDto>();
                config.CreateMap<PunishmentInfoSynchronizationQuery, AchievementPunishmentInfo>();

                #endregion

                #region CompetitionGroupingInfo

                config.CreateMap<GroupingInfoSynchronizationQuery, CompetitionGroupingInfo>();
                config.CreateMap<EmployeeInfo, GroupingEmployeeInfo>();

                #endregion

                #region EventsSession
                config.CreateMap<AddEventsSessionInfoQuery, EventsSession>();
                config.CreateMap<EventsSessionInfoSynchronizationQuery, EventsSession>();
                #endregion

                #region Competition

                config.CreateMap<EditCompetitionQuery, Competition>();
                config.CreateMap<Competition, GetCompetitionDetailsDto>();
                config.CreateMap<Competition, GetCompetitionSelectItemQuery>();
                config.CreateMap<Competition, GetCompetitionListDto>();
                config.CreateMap<GetCompetitionListDto, Competition>();
                config.CreateMap<Competition, GetYearCompetitionNameDto>(); 
                config.CreateMap<Competition, GetPageCompetitionKHDDto>();
                config.CreateMap<CompetitionSynchronizationQuery, Competition>();

                #endregion

                #region Category

                #region get
                config.CreateMap<Category, CategoryDto>();
                config.CreateMap<CategoryDto, Category>();
                config.CreateMap<GetListCategoryDto, Category>();
                config.CreateMap<Category, GetListCategoryDto>();
                config.CreateMap<GetCategoryEditDto, Category>();
                config.CreateMap<Category, GetCategoryEditDto>();
                #endregion

                #region add
                config.CreateMap<AddCategoryQuery, Category>();
                config.CreateMap<Category, AddCategoryQuery>();
                #endregion

                #region update
                config.CreateMap<Category, UpdateCategoryQuery>();
                config.CreateMap<UpdateCategoryQuery, Category>();
                #endregion

                #region delete
                config.CreateMap<DeleteCategoryQuery, Category>();
                config.CreateMap<Category, DeleteCategoryQuery>();
                #endregion

                #endregion

                #region Feedback

                #region Add

                config.CreateMap<AddFeedbackQuery, Feedback>();
                config.CreateMap<Feedback, AddFeedbackQuery>();

                #endregion

                #endregion

                #region News

                #region Add

                config.CreateMap<AddInformationQuery, Information>();
                config.CreateMap<Information, AddInformationQuery>();
                config.CreateMap<RegistrationInfo, AddRegistrationInfoQuery>();
                config.CreateMap<AddRegistrationInfoQuery, RegistrationInfo>();

                #endregion

                #region Update

                config.CreateMap<UpdateInformationQuery, Information>();
                config.CreateMap<Information, UpdateInformationQuery>();

                #endregion

                #region Delete

                config.CreateMap<DeleteInformationQuery, Information>();
                config.CreateMap<Information, DeleteInformationQuery>();

                #endregion

                #region Get

                config.CreateMap<GetInformationQuery, Information>();
                config.CreateMap<Information, GetInformationQuery>();
                config.CreateMap<Information, GetByCategoryIdToNewsDto>();
                config.CreateMap<GetByCategoryIdToNewsDto, Information>();

                #endregion

                #endregion

                #region ProjectType

                #region Add

                config.CreateMap<AddProjectTypeQuery, ProjectType>();
                config.CreateMap<ProjectType, AddProjectTypeQuery>();

                #endregion

                #region Get

                config.CreateMap<ProjectType, ProjectTypeDto>();
                config.CreateMap<ProjectTypeDto, ProjectType>();
                config.CreateMap<ProjectType, GetPageProjectTypeKHDDto>();

                #endregion

                #region Update

                config.CreateMap<UpdateProjectTypeStateQuery, ProjectType>();
                config.CreateMap<ProjectType, UpdateProjectTypeStateQuery>();

                #endregion

                #region Delete

                config.CreateMap<DeleteProjectTypeQuery, ProjectType>();
                config.CreateMap<ProjectType, DeleteProjectTypeQuery>();

                #endregion

                #endregion

                #region CompetitionProject

                config.CreateMap<EditCompetitionProjecQuery, CompetitionProject>();
                config.CreateMap<CompetitionProject, GetCompetitionPorjectDetailsDto>();
                config.CreateMap<RegistrationInfo, GetGroupListDto>();
                config.CreateMap<GetGroupListDto, RegistrationInfo>();
                config.CreateMap<CompetitionProject, GetCompetitionProjectNameDto>();
                config.CreateMap<CompetitionProject, GetPageCompetitionPorjectKHDDto>();
                config.CreateMap<CompetitionPorjectSynchronizationQuery, CompetitionProject>();

                #endregion

                #region Project

                #region Get

                config.CreateMap<Project, ProjectDto>();
                config.CreateMap<ProjectDto, Project>();
                config.CreateMap<Project, GetPageProjectKHDDto>();

                #endregion

                #region Add

                config.CreateMap<AddProjectInfoQuery, Project>();
                config.CreateMap<Project, AddProjectInfoQuery>();


                #endregion

                #region Update

                config.CreateMap<UpdateProjectStateQuery, Project>();
                config.CreateMap<Project, UpdateProjectStateQuery>();
                config.CreateMap<UpdateProjectInfoQuery, Project>();
                config.CreateMap<Project, UpdateProjectInfoQuery>();

                #endregion

                #endregion

                #region Employee
                config.CreateMap<AddEmployeeQuery, Employee>();
                config.CreateMap<EmployeeRegisterQuery, Employee>();

                config.CreateMap<Employee, EmployeeDto>();
                config.CreateMap<EmployeeDto, Employee>();

                config.CreateMap<Employee, UpdateEmployeeQuery>();
                config.CreateMap<UpdateEmployeeQuery, Employee>();

                config.CreateMap<WeChatEmployeeDto, Employee>();
                config.CreateMap<Employee, WeChatEmployeeDto>();

                config.CreateMap<AddEmployeeQuery, Employee>();
                config.CreateMap<Employee, AddEmployeeQuery>();


                #endregion

                #region Team

                config.CreateMap<WeChatTeamDto, Team>();
                config.CreateMap<Team, WeChatTeamDto>();

                #endregion

                #region PaymentOrderInfo
                config.CreateMap<AddPaymentOrderInfoQuery, PaymentOrderInfo>();
                config.CreateMap<PaymentOrderInfo, GetPriceInfoQuery>();
                config.CreateMap<PaymentOrderOperationInfoListDto, PaymentOrderOperationInfo>();
                config.CreateMap<PaymentOrderOperationInfo, PaymentOrderOperationInfoListDto>();

                #endregion

                #region  ClientLog

                config.CreateMap<AddClientLogQuery, ClientLog>();

                #endregion

                #region RegistrationInfo
                config.CreateMap<GetRegistrationInfoQuery, RegistrationInfo>();
                config.CreateMap<AddWeChatRegistrationQuery, RegistrationInfo>();

                #endregion


            });
        }

        public override void Initialize()
        {
            var thisAssembly = typeof(SportsPlatformApplicationModule).GetAssembly();

            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddMaps(thisAssembly)
            );
        }
    }
}
